#include "gamestate.h"

#include "link.h"
#include "module.h"
#include "ship.h"

GameState* gamestate;

Ship* GameState::CreateShip(float x, float y){
    Ship* ship = new Ship(x, y);
    ships.push_back(ship);
    return ship;
}

Module* GameState::CreateModule(){
    Module* module = new Module(1, 1);
    modules.push_back(module);
    return module;
}

Module* GameState::FindModule(unsigned int id){
    for(auto module:modules){
        if(module->CheckID(id)){
            return module;
        }
    }
    return nullptr;
}

Link* GameState::FindLink(unsigned int id){
    Link* link;
    for(auto module:modules){
        link = module->CheckLinkID(id);
        if(link){
            return link;
        }
    }
    return nullptr;
}

Module* GameState::FindLinkParentModule(unsigned int id){
    Link* link;
    for(auto module:modules){
        link = module->CheckLinkID(id);
        if(link){
            return module;
        }
    }
    return nullptr;
}
